<template>
    <div class="home">
        <header>
            <div class="top">
                <span></span>
                <p> 
                    <b></b>
                    <span>Chicken Music</span>
                </p>
                <i class="iconfont" @click="changeAlert(true)">&#xe67e;</i>
            </div>
            <div class="link">
                <router-link tag="span" to="/recommend">推荐</router-link>
                <router-link tag="span" to="/singer">歌手</router-link>
                <router-link tag="span" to="/ranking">排行</router-link>
                <router-link tag="span" to="/search">搜索</router-link>
            </div>
        </header>
        <main>
            <router-view/>
        </main>   
        <Audio @popup="popup" v-if="sings.length"/>
        <PlayList v-if="audioList" @popup="popup"/> 
        <Alert v-if="alertFlag"/>
        <PublicAlert v-if="PublicAlertFlag"/>
        <transition name="ran">
            <Audioran v-if="audioranFlag"/>
        </transition>
    </div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import Audio from '@/components/Audiopaly.vue'
import PlayList from '@/components/PlayList.vue'
import Alert from '@/components/Alert.vue'
import Audioran from '@/components/Audioran.vue'
import PublicAlert from '@/components/PublicAlert.vue'
export default {
    data(){
        return{
            audioList: false,
            flag: false
        }
    },
    computed: {
        ...mapState(['alertFlag', 'PublicAlertFlag', 'audioFlag', 'audioranFlag', 'sings'])
    },
    components: {
        Audio,
        PlayList,
        Alert,
        PublicAlert,
        Audioran
    },
    methods: {
        ...mapMutations(['changeAlert']),
        popup(){
            this.audioList = !this.audioList
        },     
    }
}
</script>
<style lang="scss" scoped>
.home{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}
header{
    background: #222222;
    height: 88px;
}
header .top{
    display: flex;
    height: 44px;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    color: #ffcd32;
    font-size: 18px;
    p{
        line-height: 32px;
    }
    b{
        display: inline-block;
        width: 30px;
        height: 32px;
        background-image: url('');
        background-size: cover;
        vertical-align: middle;
        margin-right: 5px;
        font-family: ' 微软雅黑';
    }
    i.iconfont{
        font-size: 20px;
        font-weight: 600;
    }
}
.link{
    height: 44px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    color: hsla(0,0%,100%,.5);  
    font-size: 14px;      
    span{
        padding-bottom: 5px; 
        border-bottom: 2px solid #222222;
    }
    .router-link-active{
        color: #ffcd32;
        border-bottom-color: #ffcd32;
    }
}
main{
    flex: 1;
    overflow: hidden;
}
.ran-enter, .ran-leave-to{
    left: -100%;
    top: 100%;
}
</style>